import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-08-17
 * Time: 17:46
 */
public class Test {
    public static void main(String[] args) {
        int[] array = new int[]{1,2,3,4,5};
        String ret = myToString(array);
        System.out.println(ret);
    }

    public static String myToString(int[] array) {
        if(array == null || array.length == 0) {
            return null;
        }
        String ret1 = "[";
        for (int i = 0; i < array.length; i++) {
            ret1 += array[i];
            if(i < array.length-1) {
                ret1 += ",";
            }
        }
        ret1 += "]";
        return ret1;
    }
    public static void main1(String[] args) {
        int[] array = new int[]{1,2,3,4,5};
        for (int i = 0; i < array.length; i++) {
            System.out.println(" " + array[i]);
        }

        for (int x:array) {
            System.out.print(x);
        }
        System.out.println(Arrays.toString(array));
    }
}
